package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Scholarship;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ScholarshipMapper extends BaseMapper<Scholarship> {



    @Select("select * from scholarship where( scholarship_name like concat('%',#{scholarship_name},'%') or scholarship_grade like concat('%',#{scholarship_name},'%')) and scholarship_deleted = 0 limit #{start},#{pageSize}")
    List<Scholarship> selectPage(@Param("scholarship_name") String scholarship_name, @Param("start")Integer start, @Param("pageSize")Integer pageSize);


    @Select("select count(*) from scholarship where scholarship_name like concat('%',#{scholarship_name},'%') and scholarship_deleted = 0 " )
    Integer selectTotal(@Param("scholarship_name") String scholarship_name);

    @Insert("insert into scholarship(scholarship_name,scholarship_grade,scholarship_level,scholarship_amount) values(#{scholarship_name},#{scholarship_grade},#{scholarship_level},#{scholarship_amount})")
    int insert (Scholarship scholarship);

    @Update("update scholarship set scholarship_name =#{scholarship_name},scholarship_grade =#{scholarship_grade},scholarship_level =#{scholarship_level},scholarship_amount =#{scholarship_amount} where scholarship_no =#{scholarship_no}and scholarship_deleted = 0 ")
    void update(Scholarship scholarship);

  /*  @Delete("delete from scholarship where scholarship_no = #{scholarship_no}")
    void delete (Integer scholarship_no);*/

    @Update("update Scholarship set scholarship_deleted=1 where scholarship_no=#{scholarship_no} and scholarship_deleted=0")
    void delete(Integer scholarship_no);









//    @Select("select * from scholarship where scholarship_id = #{student_scholarship_id}")
//    List<Scholarship> selectByScholarship_id(String scholarship_id);
//    @Select("select * from scholarship")
//    public List<Scholarship> find();
//
//    @Insert("insert into scholarship value(#{scholarship_name},#{scholarship_grade},#{scholarship_level},#{scholarship_amount})")
//   public  int insert(Scholarship scholarship);


}
